#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>

using std::cout;
using std::endl;
using std::cin;
using std::ostream_iterator;
using std::istream_iterator;
using std::vector;
using std::copy;

void test()
{
    istream_iterator<int> isi(cin);
    /* cout << "111" << endl; */
    vector<int> vec;
    /* cout << "222" << endl; */
    /* copy(isi, istream_iterator<int>(), vec.begin()); */
    //对于vector而言，如果没有预留空间的话，最好使用push_back
    //插入元素
    copy(isi, istream_iterator<int>(), std::back_inserter(vec));
    /* cout << "333" << endl; */
    //可以看成是遍历vector
    copy(vec.begin(), vec.end(), 
         ostream_iterator<int>(cout, "  "));
    cout << endl;
    /* cout << "444" << endl; */
}

int main(int argc, char **argv)
{
    test();
    return 0;
}

